<?php use_helper('I18N') ?>
<script type="text/javascript">
function formchecking(){	
	var txtusername = document.getElementById('username').value;
	var txtpassword = document.getElementById('password').value;
	
	if (txtusername.length <= 0) {
		alert('Please enter your username');
		return false;
	} else {
		if (txtpassword.length <= 0) {
			alert('Please enter your password');
			return false;
		}
	}
	
	document.getElementById('frmlogin').submit();
}

function DetectEnterPressed(e) {
	var characterCode;
	if(e && e.which){ // NN4 specific code
		e = e;
		characterCode = e.which;
	} else {
		e = event;
		characterCode = e.keyCode; // IE specific code
	}

	if (characterCode == 13){
		if(document.getElementById('username').value!="" && document.getElementById('password').value!=""){
			document.getElementById('frmlogin').submit();
		}
	}
}
</script>

<?php echo form_tag('user/login', array('id' => 'frmlogin', 'name' => 'frmlogin')) ?>

<table class="main">
	<tr>
    	<td valign="top"></td>
        <td></td>
        <td valign="top" align="center">
        	<br /><br />
            <span class="title">PLEASE ENTER YOUR DETAILS</span>
            <br /><br />
            <table width="240">
            	<tr>
                	<td align="left" colspan="2">User Name:</td>
                </tr>
                <tr>
                	<td colspan="2" align="left"><?php echo input_tag('username', null, array("onkeypress"=>"javascript:return DetectEnterPressed(event);")) ?></td>
                </tr>
                <tr>
                	<td align="left" colspan="2">Password:</td>
                </tr>
                <tr>
                	<td colspan="2" align="left"><?php echo input_password_tag('password', null, array("onkeypress"=>"javascript:return DetectEnterPressed(event);")) ?></td>
                </tr>
                <!--tr>
                	<td align="left"><a href="/user/forgetpass">Forget Password</a></td>
                    <td align="right"><a href="/user/changepass">Change Password</a></td>
                </tr-->
                <tr>
                	<td colspan="2" align="left"><img name="btnLogin" id="btnLogin" onmouseover="roll_over('btnLogin', '/images/login_btnAF.jpg')" onmouseout="roll_over('btnLogin', '/images/login_btn.jpg')" src="/images/login_btn.jpg" onClick="return formchecking();"/></td>
                </tr>
                <tr>
                	<td colspan="2" class="error" align="left">
                	<?php
						if(!empty($error_message)){
							echo $error_message;
							$error_message='';
						}
					?>
                	</td>
                </tr>
            </table>    
        </td>
    </tr>
</table>

</form>
